package com.homesoft.runtime.metadata.modle;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

public class ExtendDataList extends NotifierList<String, ExtendDataItem> implements IExtendDataList {

	/**
	 * @param owner
	 * @param memberName
	 */
	public ExtendDataList(IOwnerAware owner, String memberName) {
		super(owner, memberName);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.homesoft.runtime.metadata.modle.IExtendDataList#Assign(com.homesoft
	 * .runtime.metadata.modle.IExtendDataList)
	 */
	@Override
	public void Assign(IExtendDataList list) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.homesoft.runtime.metadata.modle.IExtendDataList#ChangeItemKey(com
	 * .homesoft.runtime.metadata.modle.IExtendDataItem, java.lang.String)
	 */
	@Override
	public boolean ChangeItemKey(IExtendDataItem item, String newKey) {
		if (this.ContainsKey(newKey)) {
			return false;
		}
		return super.ChangeItemKey((ExtendDataItem) item, newKey);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.homesoft.runtime.metadata.modle.IExtendDataList#GetBoolean(java.lang
	 * .String, boolean)
	 */
	@Override
	public boolean GetBoolean(String key, boolean defaultValue) {
		ExtendDataItem item = super.get(key);
		return Boolean.valueOf(item.getValue());
	}

	@Override
	public String GetValue(String key) {
		ExtendDataItem item = super.get(key);
		return item.getValue();
	}

	@Override
	public boolean HasExtendData(String key, String value) {
		if (this.ContainsKey(key)) {
			return this.get(key).getValue().equals(value);
		}
		return false;
	}

	@Override
	public boolean HasExtendData(String key) {
		return this.ContainsKey(key);
	}

	@Override
	public void RemoveByKey(String key) {
		this.remove(key);
	}

	@Override
	public void SetValue(String key, String value) {
		ExtendDataItem item = new ExtendDataItem(key,value);
		this.add(item);
	}

	@Override
	public String GetKeyForItem(ExtendDataItem item) {
		return item.getKey();
	}
}
